USE [DeltaFlex]
GO

IF (OBJECT_ID('dbo.ORDRE_TREBALL')) IS NOT NULL
	DROP TABLE dbo.ORDRE_TREBALL
GO

SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

CREATE TABLE ORDRE_TREBALL(
	IDORDRE int NOT NULL,
	IDCLIENT int NOT NULL,
	IDIMPRESOR int NOT NULL,
	DATAENTREGA date NOT NULL,
	HORAENTREGA varchar(20) NOT NULL,
    REFERENCIACLIENT varchar(100) NOT NULL,
	IDTREBALL varchar(100) NOT NULL,
	PEDIDOCLIENT varchar(100) NOT NULL,
	TIPOTREBALL varchar(50) NOT NULL,
	TIPOCAIXA varchar(50) NOT NULL,
	FITXA varchar(20) NOT NULL,
	TIPOMESURES varchar(50) NOT NULL,
	MESURES varchar(50) NOT NULL,
	NUMTROQUEL varchar(50) NOT NULL,
	POSES varchar(20) NOT NULL,
	MATERIALADJUNT varchar(250),
	MATERIALTORNAR varchar(250),
	COLORS varchar(250) NOT NULL,
	TIPOCLITXE varchar(250) NOT NULL,
	IDMAQUINA int NOT NULL,
	DEFLACCIO varchar(10) NOT NULL,
	FEINAFER varchar(500) NOT NULL,
	OBSERVACIONS varchar(500) NOT NULL,
	NOMARXIU varchar(100) NOT NULL	

 CONSTRAINT PK_Ordre_Treball PRIMARY KEY CLUSTERED 
(
	IDORDRE ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]


IF (OBJECT_ID('SEQ_ORDRE_TREBALL')IS NOT NULL)
	DROP SEQUENCE SEQ_ORDRE_TREBALL
GO

CREATE SEQUENCE SEQ_ORDRE_TREBALL
	START WITH 1
    INCREMENT BY 1
    MINVALUE 1
    MAXVALUE 9223372036854775807;

GO